﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace System
{
    public static class TypeExtensions
    {
        /// <summary>
        /// 指示一个类型是否继承自某个类型或实现某个接口
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="type"></param>
        /// <returns></returns>
        public static bool Is<T>(this Type type)
            where T : class
        {
            return type.GetInterface(typeof(T).FullName) != null
                || (type.BaseType != typeof(object) && type.BaseType.Is<T>());
        }
    }
}
